package controller;

import mapper.TransferFile;
import model.Bill;
import service.MainServices;
import view.Home;

import java.time.LocalDateTime;
import java.util.Scanner;

/**
 * @InterfaceName: MainController
 * @Description:
 * @Author: YourName
 * @Date: 2024/12/27
 */
public class MainController {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        MainServices mainServices = new MainServices();
        Home.login();
        while (true){
            int input = scanner.nextInt();
            scanner.nextLine();  // 消耗换行符
            switch (input){
                case 7:
                    System.out.println("结束运行");
                    return;
                case 1:
                    System.out.println("请输入收入信息：");
                    System.out.println();
                    System.out.println("金额：");
                    input = scanner.nextInt();
                    scanner.nextLine();
                    System.out.println("类别（如工资、奖金等）：");
                String type = scanner.nextLine();
                    System.out.println("备注：");
                String notes = scanner.nextLine();
                Bill bill = new Bill(Home.time(),input,type,notes);
                    System.out.println(mainServices.RecordIincome(bill));
                    Home.login();
                    break;
                case 2:
                    System.out.println("请输入支出信息：");/////dddd
                    System.out.println();//dadadadad
                    System.out.println("金额：");
                    input = scanner.nextInt();
                    scanner.nextLine();
                    System.out.println("类别（如工资、奖金等）：");
                    String type1 = scanner.nextLine();
                    System.out.println("备注：");
                    String notes1 = scanner.nextLine();
                    Bill bill2 = new Bill(Home.time(),input,type1,notes1);
                    System.out.println(mainServices.RecordExpenses(bill2));
                    Home.login();
                    break;
                case 3:
                    mainServices.ViewAllBills();
                    Home.login();
                case 4:
                    Boolean key = true;
                    while (key){
                        System.out.println("请输入插叙账单的日期:输入0 结束插叙 ");
                        String inputTime = scanner.nextLine();
                        mainServices.AnViewAllBills(inputTime);
                        if (inputTime.equals("0")){
                            key = !key;
                        }
                    }
                    break;
                case 5:
                    System.out.println("请输入限额：输入0解除限额");//
                    double limitMoney = scanner.nextDouble();
                    System.out.println(mainServices.limitMoney(limitMoney));
                    Home.login();
                    break;
                case 6:
                    System.out.println("查看月度统计");
                    System.out.println("月度支出");
                    System.out.println(TransferFile.getExpenses());
                    System.out.println("月度收入");
                    System.out.println(TransferFile.getIncome());
                default:
                    System.out.println("请输入正确的数字");

            }
        }

    }
}
